package com.woniu.dao;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.woniu.entity.Admin;
import com.woniu.entity.User;

import tk.mybatis.mapper.common.Mapper;

public interface AdminMapper extends Mapper<Admin> {

	/**
	 * List<Student> selectByDeptAndSex(@Param("dept") String dept, @Param("sex")
	 * String sex);
	 * 
	 * @return 管理员首页获取注册用户信息，用于在首页显示数据
	 */
	List<User> getUserList();

	/**
	 * @param name
	 * @param password
	 * @param phone
	 * @param role
	 * @return
	 */
	Admin selectAdmin(@Param("name") String name, @Param("password") String password, @Param("phone") String phone,
			@Param("role") String role);

	/**
	 * @param name
	 * @param phone
	 * @return
	 */
	@Select("select count(*) from t_admin where adminName=#{name} AND adminPhone=#{phone}")
	int selectForgetAdmin(@Param("name") String name, @Param("phone") String phone);

	/**
	 * @param name
	 * @param phone
	 * @param newPassTwo
	 * @return
	 */
	@Update("update t_admin set adminPass=#{newPass} where adminName=#{name} and adminPhone=#{phone}")
	int updataForgetPass(@Param("name") String name, @Param("phone") String phone, @Param("newPass") String newPassTwo);

	/**
	 * @param absolutePath
	 * @return
	 */
	@Update("update t_admin set headImg=#{path} where adminId=#{adminid}")
	int updateAdminHeadImg(@Param("path") String absolutePath, @Param("adminid") String adminId);

	/**
	 * @param pass
	 * @return
	 */
	@Update("update t_admin set adminPass=#{pass} where adminId=#{adminid}")
	int updateAdminInfo(@Param("pass") String pass, @Param("adminid") String adminid);

	@Update("UPDATE t_admin SET  adminPass=#{adminPass} where adminName=#{adminName}")
	void updateAdminPass(@Param("adminPass") String adminPass, @Param("adminName") String adminName);

	/**
	 * @param username
	 * @return
	 */
	@Select("select * from t_admin where adminName=#{username}")
	Admin selectAdminByShiro(@Param("username") String username);
}